package com.efrei.uchat.model.croom;

import com.efrei.uchat.exception.UChatException;

public enum CroomMessageStatus {
	UNKNOWN(0),
	// query
	JOIN(1),
	LEAVE(2),
	
	// response
	SUCCESS(3),
	FORBIDDEN(4),
	ERROR(5);
	
	private int code;
	private CroomMessageStatus(int code) {
		this.code = code;
	}
	@Override
	public String toString() {
		return String.valueOf(code);
	}
	
	public static CroomMessageStatus get(int code) throws UChatException {
		for (CroomMessageStatus status : values()) {
			if(status.getCode()==code) {
				return status;
			}
		}
		throw new UChatException("Unknown CroomMessageStatus "+code);
	}
	
	public int getCode() {
		return code;
	}
};
